﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace HSIA
{
    public partial class Frm_DateFilter : Form
    {
        public Frm_DateFilter(DatabaseObject pdbo)
        {
            InitializeComponent();
            dbo = pdbo;
        }
        DatabaseObject dbo = null;
        public DateTime dtBegin;
        public DateTime dtEnd;

        private void FrmDoDate_Load(object sender, EventArgs e)
        {
            this.Text = dbo.GetLanguage(530);
            button1.Text = dbo.GetLanguage(193); //193确定
            button2.Text = dbo.GetLanguage(51);//51取消
            label1.Text = dbo.GetLanguage(497) + " :";
            label4.Text = dbo.GetLanguage(498) + " :";

            tpBegin.Value = DateTime.Now.AddHours(-6);
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (tpBegin.Text.Trim() == "")
            {
                MessageBox.Show(dbo.GetLanguage(500), dbo.GetLanguage(141), MessageBoxButtons.OK, MessageBoxIcon.Information);//"请选择开始时间!"
                tpBegin.Focus();
                return;
            }
            if (tpEnd.Text.Trim() == "")
            {
                MessageBox.Show(dbo.GetLanguage(501), dbo.GetLanguage(141), MessageBoxButtons.OK, MessageBoxIcon.Information);//"请选择结束时间!");
                tpEnd.Focus();
                return;
            }

            dtBegin = tpBegin.Value;
            dtEnd = tpEnd.Value;
            TimeSpan TSpan = dtEnd - dtBegin;
            if (dtEnd < dtBegin)
            {
                MessageBox.Show(dbo.GetLanguage(99), dbo.GetLanguage(141), MessageBoxButtons.OK, MessageBoxIcon.Information);
                tpEnd.Focus();//"结束日期小于开始日期,请重新调整!", "提示", 
                return;
            }
            else if (TSpan.TotalDays > 1)
            {
                MessageBox.Show(dbo.GetLanguage(313), dbo.GetLanguage(141), MessageBoxButtons.OK, MessageBoxIcon.Information);
                tpEnd.Focus();//"结束日期小于开始日期,请重新调整!", "提示", 
                return;
            }
            this.DialogResult = DialogResult.OK;
        }
    }
}